package org.fengling.readingplatform.novel.service.impl;

import org.fengling.readingplatform.model.entity.novel.Chapter;
import org.fengling.readingplatform.model.vo.novel.ChapterVo;
import org.fengling.readingplatform.novel.mapper.ChapterMapper;
import org.fengling.readingplatform.novel.service.ChapterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.CompletableFuture;

@Service
public class ChapterServiceImpl implements ChapterService {

    @Autowired
    private ChapterMapper chapterMapper;

    // 查询小说章节的方法
    @Override
    @Async("contentThreadPoolTaskExecutor")
    public CompletableFuture<Chapter> getContent(long novelId, long chapterId) {
        return CompletableFuture.supplyAsync(() -> {
            return chapterMapper.getContent(novelId, chapterId);
        });
    }


    // 查询小说所有章节
    @Override
    public List<ChapterVo> getAllChapter(long novelId) {
        return chapterMapper.getAllChapter(novelId);
    }


}
